package com.itheima.boottlias.mapper;

import com.github.pagehelper.Page;
import com.itheima.boottlias.domain.entity.NameNum;
import com.itheima.boottlias.domain.entity.NameValue;
import com.itheima.boottlias.domain.pojo.Emp;
import com.itheima.boottlias.domain.query.QueryParam;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**
 * @author ghy
 * @version 1.0
 * @since 2025-07-11 15:04
 */
@Mapper
public interface EmpMapper {

    // /**
    //  * 统计数量
    //  * @return
    //  */
    // @Select("select count(*) from emp e left join dept d on e.dept_id = d.id")
    // Long count();
    //
    // /**
    //  * 分页查询
    //  * @param start
    //  * @param pageSize
    //  * @return
    //  */
    // @Select("select e.*, d.name dept_name from emp e left join dept d on e.dept_id = d.id limit #{start}, #{pageSize}")
    // List<Emp> pageQuery(@Param("start") Integer start, @Param("pageSize") Integer pageSize);

    // @Select("select e.*, d.name dept_name from emp e left join dept d on e.dept_id = d.id")
    // Page<Emp> list();

    // @Select("select e.*, d.name dept_name from emp e left join dept d on e.dept_id = d.id " +
    //         " where e.name like concat('%', #{name}, '%') " +
    //         " and e.gender = #{gender} " +
    //         " and e.entry_date between #{begin} and #{end}")
    // Page<Emp> list(@Param("name") String name, @Param("gender") Integer gender,
    //                @Param("begin") LocalDate begin, @Param("end") LocalDate end);

    /**
     * 条件查询
     * @param empQueryParam 条件
     * @return
     */
    // @Select("select e.*, d.name dept_name from emp e left join dept d on e.dept_id = d.id " +
    //                 " where e.name like concat('%', #{name}, '%') " +
    //                 " and e.gender = #{gender} " +
    //                 " and e.entry_date between #{begin} and #{end}")
    Page<Emp>  findByCondition(QueryParam queryParam);

    void insert(Emp emp);

    /**
     * 根据ID批量删除
     * @param ids
     */
    void deleteByIds(@Param("ids") Integer[] ids);

    List<String> selectImagesByIds(@Param("ids") Integer[] ids);

    /**
     * 根据ID查询员工信息及工作经历信息
     * @param id
     * @return
     */
    Emp findById(Integer id);

    /**
     * 根据ID更新
     * @param emp
     */
    void updateById(Emp emp);

    Integer countByUsername(String username);

    /**
     * 统计各个岗位人数
     * @return
     */
    List<NameNum> getEmpJobData();

    /**
     * 统计各个性别人数
     * @return
     */
    List<NameValue> getEmpGenderData();

    List<Emp> findAll();

    Emp findByUsername(String username);
}
